﻿using System;
using System.Windows;
using System.Windows.Controls;

using Resn.WhuPub.BLL;
using System.Deployment.Application;

namespace Resn.WhuPub.WPFClientUI
{
        /// <summary>
        /// Page1.xaml 的交互逻辑
        /// </summary>
        public partial class MainPage : Page
        {
                private readonly GlobalManager _gm = GlobalManager.Instance;

                public MainPage()
                {
                        InitializeComponent();

                        //VersionTextBlock.Text = "当前版本:" + ApplicationDeployment.CurrentDeployment.CurrentVersion;                        
                }

                private void InsideBusinessButton_OnClick(object sender, RoutedEventArgs e)
                {
                        if (_gm.LoginEmployee == null)
                        {
                                MessageBox.Show("请先登录系统");
                                return;
                        }

                        MainFrame.Navigate(new Uri("InsideBusinessPage.xaml", UriKind.Relative));
                }

                private void OutsideBusinessButton_OnClick(object sender, RoutedEventArgs e)
                {
                        if (_gm.LoginEmployee == null)
                        {
                                MessageBox.Show("请先登录系统");
                                return;
                        }

                        MainFrame.Navigate(new Uri("OutsideBusinessPage.xaml", UriKind.Relative));
                }

                private void EmployeeBusinessButton_OnClick(object sender, RoutedEventArgs e)
                {
                        if (_gm.LoginEmployee == null)
                        {
                                MessageBox.Show("请先登录系统");
                                return;
                        }

                        MainFrame.Navigate(new Uri("EmployeeBusinessPage.xaml", UriKind.Relative));
                }

                
                private void AdminBusinessButton_Click(object sender, RoutedEventArgs e)
                {
                        if (_gm.LoginEmployee == null)
                        {
                                MessageBox.Show("请先登录系统");
                                return;
                        }

                        if (_gm.LoginEmployee.Level == EmployeeLevel.普通用户)
                        {
                                MessageBox.Show("请用更高权限用户登录");
                                return;
                        }

                        MainFrame.Navigate(new Uri("AdminBusinessPage.xaml", UriKind.Relative));
                }

                private void ExitButton_Click(object sender, RoutedEventArgs e)
                {
                        _gm.LoginEmployee = null;

                        MainFrame.Navigate(new Uri("StartPage.xaml", UriKind.Relative));
                }
                
        }
}